mini-os: work around ld bug causing stupid CTOR count
authorJeremy Fitzhardinge <jeremy@goop.org>
Fri, 19 Aug 2011 08:57:42 +0000 (09:57 +0100)
committerJeremy Fitzhardinge <jeremy@goop.org>
Fri, 19 Aug 2011 08:57:42 +0000 (09:57 +0100)
commitb57bd6d2732468362c1dd3be0b26ccf5f4afbf0d
tree9c5b64dd6eeed9cb071da6223ce5bc5191221899
parent51f03ec421fb50d2c24a48716a222b8646eab305
mini-os: work around ld bug causing stupid CTOR count

I'm seeing pvgrub crashing when running CTORs.  It appears its because
the magic in the linker script is generating junk.  If I get ld to
output a map, I see:

.ctors          0x0000000000097000       0x18
                0x0000000000097000                __CTOR_LIST__ = .
                0x0000000000097000        0x4 LONG 0x25c04
                (((__CTOR_END__ - __CTOR_LIST__) / 0x4) - 0x2)
 *(.ctors)
 .ctors         0x0000000000097004       0x10
                /home/jeremy/hg/xen/unstable/stubdom/mini-os-x86_32-grub/mini-os.o
                0x0000000000097014        0x4 LONG 0x0
                0x0000000000097018                __CTOR_END__ = .

In other words, somehow ((0x97018-0x97000) / 4) - 2 = 0x25c04

The specific crash is that the ctor loop tries to call the NULL
sentinel.  I'm seeing the same with the DTOR list.

Avoid this by terminating the loop with the NULL sentinel, and get rid
of the CTOR count entirely.

From: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Keir Fraser <keir@xen.org>
extras/mini-os/arch/ia64/minios-ia64.lds
extras/mini-os/arch/x86/minios-x86_32.lds
extras/mini-os/arch/x86/minios-x86_64.lds
extras/mini-os/main.c